﻿@model JuCheap.Core.Models.ViewModels.DepartmentGroupViewModel
@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Layout_Content.cshtml";
}
@section styles
    {
    <link href="~/js/plugins/select2/css/select2.css" rel="stylesheet" />
    <link href="~/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
}
@section scripts
    {
    <script src="~/js/plugins/iCheck/icheck.min.js"></script>
        <script src="~/js/jquery.validate.js"></script>
        <script src="~/js/jquery.validate.unobtrusive.js"></script>
        <script src="~/js/base.js"></script>
        <script src="~/js/moment.js"></script>
        <script src="~/js/bootstrap-datetimepicker.min.js"></script>
    <environment names="Staging,Production">

        <script src="~/js/validate.min.js" asp-append-version="true"></script>
        <script src="~/js/base.min.js" asp-append-version="true"></script>
    </environment>
    <script src="~/js/plugins/select2/js/select2.js"></script>
    <script src="~/js/BindSelect.js"></script>
    <script>
        $("#btnBack").bind("click", function (e) {
            XPage.GoTo(e.target, "@Url.Action("Index")");
        });
        //$("#OpenCycles").select2();
        BindSelect("Devicess", "/HardWare/GetHardWares");
        BindSelect("Workerss", "/Worker/GetWorkers");

        //$('#OpenCycles').change(function () {
        //    var o = document.getElementById('OpenCycles').getElementsByTagName('option');
        //    var all = "";
        //    for (var i = 0; i < o.length; i++) {
        //        if (o[i].selected) {
        //            all += o[i].value + ",";
        //        }
        //    }
        //    all = all.substr(0, all.length - 1);
        //    $("#OpenCycle").val(all);
        //});
        $('#Devicess').change(function () {
            var o = document.getElementById('Devicess').getElementsByTagName('option');
            var all = "";
            for (var i = 0; i < o.length; i++) {
                if (o[i].selected) {
                    all += o[i].value + ",";
                }
            }
            all = all.substr(0, all.length - 1);
            $("#DevicesId").val(all);
        });
        $('#Workerss').change(function () {
            var o = document.getElementById('Workerss').getElementsByTagName('option');
            var all = "";
            for (var i = 0; i < o.length; i++) {
                if (o[i].selected) {
                    all += o[i].value + ",";
                }
            }
            all = all.substr(0, all.length - 1);
            $("#WorkersId").val(all);
        });

        //$("#OpenCycle").val(['1', '2']).trigger('change');
        //$("#Workers").trigger('change');

        $(function () {
            $('#OpenDate').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn')
            });
        });
    </script>
}

<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5></h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <form asp-controller="DepartmentGroup" asp-action="Add" class="form-horizontal" method="POST">
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="Name"></label>
                    <div class="col-sm-8">
                        <input asp-for="Name" class="form-control" placeholder="群组名称" />
                        <span asp-validation-for="Name"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="OpenCycle"></label>
                    <div class="col-sm-8">
                        <div class='input-group date' id='OpenDate'>
                            <input type='text'id='OpenCycle' name="OpenCycle" class="form-control" />
                            <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar"></span>
                            </span>
                        </div>
                        <span asp-validation-for="OpenCycle"></span>
                    </div>
                </div>

                @*<div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="DevicesId"></label>
                    <div class="col-sm-8">
                        <select name="Devicess" id="Devicess" class="form-control" placeholder="设备" multiple="multiple"></select>
                        <span asp-validation-for="DevicesId"></span>
                        <input type="hidden" name="DevicesId" id="DevicesId" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="WorkersId"></label>
                    <div class="col-sm-8">
                        <div class="col-sm-10">
                            <select name="Workerss" id="Workerss" class="form-control" placeholder="员工" multiple="multiple"></select>
                        </div>
                        <span asp-validation-for="WorkersId"></span>
                        <input type="hidden" name="WorkersId" id="WorkersId" />
                    </div>
                </div>*@
                <div class="form-group">
                    <div class="col-sm-offset-  3 col-sm-8">
                        <button class="btn btn-info" type="submit">保存</button>
                        <button class="btn btn-white" type="button" id="btnBack">返回</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

